package com.gee.spring.boot.starter.opengemini.core.domain;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
 * @author gepengjun
 * @since 2024/4/28 8:29
 */
public class SelectFunc {

    public static final SelectFunc COUNT = new SelectFunc("count", null);
    public static final SelectFunc FIRST = new SelectFunc("first", null);
    public static final SelectFunc LAST = new SelectFunc("last", null);
    public static final SelectFunc MIN = new SelectFunc("min", null);
    public static final SelectFunc MAX = new SelectFunc("max", null);

    public static final String TOP = "top";

    public static final String BOTTOM = "bottom";

    public static final String PERCENTILE = "percentile";

    public static final String SAMPLE = "percentile";

    public static final String PERCENTILE_OGSKETCH = "percentile_ogsketch";



    private String keyWork;

    private List<Object> paramList;

    public SelectFunc(String keyWork, List<Object> paramList) {
        this.keyWork = keyWork;
        this.paramList = paramList;
    }

    public String getKeyWork() {
        return keyWork;
    }

    public void setKeyWork(String keyWork) {
        this.keyWork = keyWork;
    }

    public List<Object> getParamList() {
        return paramList;
    }

    public void setParamList(List<Object> paramList) {
        this.paramList = paramList;
    }

    public static SelectFuncBuilder newBuilder() {
        return new SelectFuncBuilder();
    }

    public static final class SelectFuncBuilder {
        private String keyWork;
        private List<Object> paramList;

        private SelectFuncBuilder() {
            paramList = new ArrayList<>();
        }

        public SelectFuncBuilder keyWork(String keyWork) {
            this.keyWork = keyWork;
            return this;
        }

        public SelectFuncBuilder params(Object ... params) {
            if (params != null){
                this.paramList.addAll(Arrays.asList(params));
            }
            return this;
        }

        public SelectFunc build() {
            return new SelectFunc(keyWork, paramList);
        }
    }
}
